// 配置解析token的中间件
app.use(expressJWT({
  secret: jwtSecretKey,
}).unless({ path: [/^\/api\/admin\/login/,/^\/api\/admin\/chatGPT/,  /^\/api\/student\/upload\//, /^\/api\/student\/importExcel/] }))

// 文件上传插件
const multer = require('multer')
const path = require('path')
const fs = require("fs")

const upload = multer({
  dest: path.join(__dirname, '../public/upload/avatar')
})

// 文件上传后文件名的处理
const file = req.file
// 获取后缀
const ext = path.extname(file.originalname)
// 重命名
const random = Math.floor(Math.random() * 9999999)
let oldName = file.path //获取path: 'public\\upload\\0f625978d5d1a783b12e149718f8b634',
let newName = path.join(__dirname, '../public/upload/avatar/' + random + ext)
fs.renameSync(oldName, newName)//将老的文件名改成新的有后缀的文件 #同步写法
